Promise.any = function(promises){
    return new Promise((resolve,reject)=>{
        if(Array.isArray(Promise)){
            let errors = []
            let count = 0 
            if(promises.length===0){
                reject(new AggregateError('All promises were rejected'))
            }
            promises.forEach((item,index)=>{
               Promise.resolve(item).then(
                   (value)=>{
                       resolve(value)
                   },
                   (reason)=>{
                        count++
                        errors[index] = reason
                        count === promises.length && reject(new AggregateError(errors));
                   }
               )
            })
        }else{
            throw new TypeError('arg not a Array')
        }
    })
}